package com.epoint.rest;

import com.epoint.springtest.User;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserRest {

    @PostMapping("/loaduserinfo")
    public Map testRequestParams(@RequestParam("params") JSONObject params, HttpSession session) throws JSONException {
        User user = (User) session.getAttribute("user");
        Map<String, Object> result = new HashMap<>();
        result.put("username", user.getName());
        return result;
    }
}
